package com.example.hrmsaas.system.service.impl;

import com.example.hrmsaas.system.entity.PermissionMenu;
import com.example.hrmsaas.system.mapper.PermissionMenuMapper;
import com.example.hrmsaas.system.service.IPermissionMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 雷哥
 * @since 2021-11-10
 */
@Service
public class PermissionMenuServiceImpl extends ServiceImpl<PermissionMenuMapper, PermissionMenu> implements IPermissionMenuService {
    private Log log = (Log) LogFactory.getLog(PermissionApiServiceImpl.class);
    @Autowired
    PermissionMenuMapper menuMapper;

    @Override
    public boolean add(PermissionMenu menu) throws Exception {
        int code=menuMapper.insert(menu);
        System.out.println(code);
        Exception exception = null;
        if(code>0){
            return true;
        }else{
            assert false;
            log.info("PermissionMenuServiceImpl执行保存异常"+exception.getMessage());
            return false;
        }
    }

    @Override
    public boolean edit(PermissionMenu menu) throws Exception {
        int code=menuMapper.updateById(menu);
        Exception exception = null;
        if(code>0){
            return true;
        }else{
            assert false;
            log.info("PermissionMenuServiceImpl执行更新异常"+exception.getMessage());
            return false;
        }
    }

    @Override
    public PermissionMenu getInfoByid(String id) throws Exception {
        return menuMapper.selectById(id);
    }

    @Override
    public boolean delet(String id) throws Exception {
        int code=menuMapper.deleteById(id);
        Exception exception = null;
        if(code>0){
            return true;
        }else{
            assert false;
            log.info("PermissionMenuServiceImpl执行删除异常"+exception.getMessage());
            return false;
        }
    }
}
